/*******************************************************************************
* Project: QSAR(Cute Software Architecture) 
*
* Copyright: Copyright(C) 2024 by YuetingBen, All Rights Reserved
*
* File name: DcmDspSvc28.c
*
* Brief: ;
*
* Author: Yueting.Ben
*
* Module: Dcm
*
*******************************************************************************/

/** HEADER FILES **/
#include "DcmDspSvc28.h"
#include "DcmDsp.h"


/** MACRO DEFINITION **/


/** TYPEDEF DEFINITION **/


/** LOCAL DATA DECLARATION **/


/** GLOBAL DATA DECLARATION **/


/** LOCAL FUNCTION DECLARATION **/


/** GLOBAL FUNCTION DECLARATION **/


/** LOCAL DATA **/


/** GLOBAL DATA **/


/** LOCAL FUNCTION **/


/** GLOBAL FUNCTION **/

/*******************************************************************************
* -Name            DcmDsp_Svc28_00_Processor
* -Brief           Processor for CommunicationControl (28 hex) sub service 
* -Details         None
* -Param[in]       OpStatus: The operations status        
* -Param[in, out]  pMsgContext: Message context 
* -Param[out]      ErrorCode: Negative response code
* -Return          E_OK:          
*                  E_NOT_OK: 
*******************************************************************************/
Std_ReturnType DcmDsp_Svc28_00_Processor(
    Dcm_ExtendedOpStatusType OpStatus,
    Dcm_MsgContextType* pMsgContext,
    Dcm_NegativeResponseCodeType* ErrorCode
)
{
    Std_ReturnType retVal = E_OK;
    
    switch(Dcm_GetProgress(pMsgContext))
    {
        case DCM_PROGRESS_INITIAL:
        {
            retVal = DCM_E_PENDING;
            Dcm_SetProgress(pMsgContext, DCM_PROGRESS_LENGTH_FORMAT_CHECK);
            break;
        }
        case DCM_PROGRESS_LENGTH_FORMAT_CHECK:
        {
            retVal = DCM_E_PENDING;
            if(DCMDSPSVC28_REQ_2800_DATA_MINLENGTH == pMsgContext->reqDataLen)
            {
                Dcm_SetProgress(pMsgContext, DCM_PROGRESS_IMPLEMENTATION);
            }
            else
            {
                *ErrorCode = DCM_E_INCORRECTMES_SAGELENGTHORINVALID_FORMAT;
                retVal = E_NOT_OK;
            }
            break;
        }
        case DCM_PROGRESS_IMPLEMENTATION:
        {
            ComM_DCM_InactiveDiagnostic(ComStackConf_NetworkHandleId_0);
            pMsgContext->resDataLen = 1u;
        }
    }

    return(retVal);
}

/*******************************************************************************
* -Name            DcmDsp_Svc28_03_Processor
* -Brief           Processor for CommunicationControl (28 hex) sub service 
* -Details         None
* -Param[in]       OpStatus: The operations status        
* -Param[in, out]  pMsgContext: Message context 
* -Param[out]      ErrorCode: Negative response code
* -Return          E_OK:          
*                  E_NOT_OK: 
*******************************************************************************/
Std_ReturnType DcmDsp_Svc28_03_Processor(
    Dcm_ExtendedOpStatusType OpStatus,
    Dcm_MsgContextType* pMsgContext,
    Dcm_NegativeResponseCodeType* ErrorCode
)
{
    Std_ReturnType retVal = E_OK;

    switch(Dcm_GetProgress(pMsgContext))
    {
        case DCM_PROGRESS_INITIAL:
        {
            retVal = DCM_E_PENDING;
            Dcm_SetProgress(pMsgContext, DCM_PROGRESS_LENGTH_FORMAT_CHECK);
            break;
        }
        case DCM_PROGRESS_LENGTH_FORMAT_CHECK:
        {
            retVal = DCM_E_PENDING;
            if(DCMDSPSVC28_REQ_2803_DATA_MINLENGTH == pMsgContext->reqDataLen)
            {
                Dcm_SetProgress(pMsgContext, DCM_PROGRESS_IMPLEMENTATION);
            }
            else
            {
                *ErrorCode = DCM_E_INCORRECTMES_SAGELENGTHORINVALID_FORMAT;
                retVal = E_NOT_OK;
            }
            break;
        }
        case DCM_PROGRESS_IMPLEMENTATION:
        {
            ComM_DCM_ActiveDiagnostic(ComStackConf_NetworkHandleId_0);
            pMsgContext->resDataLen = 1u;
        }
    }
    
    return(retVal);
}


